﻿<UserControl x:Class="ScrumFactory.Projects.ProjectSummary"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             
             xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             xmlns:props="clr-namespace:ScrumFactory.Projects.Properties"        

    
             x:Name="thisView"
             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="800">
    
    

    <SF_Helpers:PanelLayout Title="{Binding PanelName}">

        <!-- TOOLBAR -->
        <SF_Helpers:PanelLayout.Toolbar>
            <ToolBar Grid.Row="0">
                <MenuItem Header="{x:Static props:Resources.Start_project}" Command="{Binding Path=StartProjectCommand}"
                          Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/startProject.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{x:Static props:Resources.Close_project}" Command="{Binding Path=CloseProjectCommand}"
                          Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/closeProject.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>                    
                </MenuItem>
                <MenuItem Header="{x:Static props:Resources.Review_report}" Command="{Binding ShowReviewReportCommand}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/preview.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{x:Static props:Resources.Project_details}" Command="{Binding EditProjectCommand}"
                          Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/projectProperties.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem                                
                    Header="{x:Static props:Resources.Suspended}"
                    IsCheckable="True"
                    IsChecked="{Binding IsSuspended}"
                    IsEnabled="{Binding CanEdit}"
                    Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/pause.png" Width="32" Height="32" Stretch="Uniform"/>
                    </MenuItem.Icon>
                </MenuItem>
            </ToolBar>
        </SF_Helpers:PanelLayout.Toolbar>

        <!-- CONTENT -->
        <SF_Helpers:PanelLayout.Content>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="240"/>
                </Grid.ColumnDefinitions>
                
                
                <StackPanel Orientation="Vertical" Grid.Column="0" >
                    <TextBlock Text="{Binding CurrentSprintLabel}"
                           Style="{StaticResource TitleTextBlock}"
                           Margin="0,5,0,20"/>
                    
                    <ContentPresenter            
                    HorizontalAlignment="Stretch" Height="200" VerticalAlignment="Top"                    
                    Content="{Binding BurndownViewModel.View}"/>
                    
                    <!-- INDICATORS -->
                    <Grid Margin="0,15,0,0">
                        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width=".3*"/>
                            <ColumnDefinition Width=".3*"/>
                            <ColumnDefinition Width=".3*"/>
                        </Grid.ColumnDefinitions>

                        <Grid Grid.Column="0" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="auto"/>
                            </Grid.RowDefinitions>
                            <TextBlock                                
                                Grid.ColumnSpan="2" Grid.Row="0"
                                Style="{StaticResource TitleTextBlock}"                                
                                Text="{x:Static props:Resources.Budget}"/>
                            <TextBlock                                 
                               Grid.Column="0" Grid.Row="1"
                               Style="{StaticResource IndicatorTextBlock}"
                               DataContext="{Binding BudgetIndicatorStatus}" Width="100" TextAlignment="Center" >
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    FontFamily="{StaticResource WideFont}" FontSize="40" FontWeight="Bold"
                                    Text="{Binding ElementName=thisView, Path=DataContext.BudgetIndicator, StringFormat='{}{0:0}'}"/>    
                                <LineBreak/>
                                <TextBlock
                                    HorizontalAlignment="Center" TextWrapping="Wrap"
                                    FontSize="{StaticResource SmallFontSize}" FontWeight="Bold"
                                    Text="{x:Static props:Resources.used_budget}"/>                        
                            </TextBlock>
                            <TextBlock 
                                Grid.Column="1" Grid.Row="1"
                                FontSize="{StaticResource SmallFontSize}"
                                TextWrapping="Wrap" VerticalAlignment="Center"
                                Text="{x:Static props:Resources.budgetIndicator_tooltip}"/>
                        </Grid>


                        <Grid Grid.Column="1" Margin="10,0,10,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="auto"/>
                            </Grid.RowDefinitions>
                            <TextBlock                                
                                Grid.ColumnSpan="2" Grid.Row="0"
                                Style="{StaticResource TitleTextBlock}"                                
                                Text="{x:Static props:Resources.Quality}"/>
                            <TextBlock                                 
                               Grid.Column="0" Grid.Row="1"
                               Style="{StaticResource IndicatorTextBlock}"
                               DataContext="{Binding QualityIndicatorStatus}" Width="100" TextAlignment="Center" >
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    FontFamily="{StaticResource WideFont}" FontSize="40" FontWeight="Bold"
                                    Text="{Binding ElementName=thisView, Path=DataContext.QualityIndicator, StringFormat='{}{0:0}'}"/>    
                                <LineBreak/>
                                <TextBlock
                                    HorizontalAlignment="Center" TextWrapping="Wrap"
                                    FontSize="{StaticResource SmallFontSize}" FontWeight="Bold"
                                    Text="{x:Static props:Resources.re_work}"/>                        
                            </TextBlock>
                            <TextBlock 
                                Grid.Column="1" Grid.Row="1"
                                FontSize="{StaticResource SmallFontSize}"
                                TextWrapping="Wrap" VerticalAlignment="Center"
                                Text="{x:Static props:Resources.qualityIndicator_tooltip}"/>
                        </Grid>

                        <Grid Grid.Column="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="auto"/>                                
                            </Grid.RowDefinitions>
                            <TextBlock                                
                                Grid.ColumnSpan="2" Grid.Row="0"
                                Style="{StaticResource TitleTextBlock}"                                
                                Text="{x:Static props:Resources.Speed}"/>
                            <TextBlock                                 
                               Grid.Column="0" Grid.Row="1"
                               Style="{StaticResource IndicatorTextBlock}"
                               DataContext="{Binding VelocityIndicatorStatus}" Width="100" TextAlignment="Center" >
                                <TextBlock
                                    HorizontalAlignment="Center"
                                    FontFamily="{StaticResource WideFont}" FontSize="40" FontWeight="Bold"
                                    Text="{Binding ElementName=thisView, Path=DataContext.VelocityIndicator, StringFormat='{}{0:0}'}"/>    
                                <LineBreak/>
                                <TextBlock
                                    HorizontalAlignment="Center" TextWrapping="Wrap"
                                    FontSize="{StaticResource SmallFontSize}" FontWeight="Bold"
                                    Text="{x:Static props:Resources.pts_hrs}"/>                        
                            </TextBlock>
                            <TextBlock 
                                Grid.Column="1" Grid.Row="1"
                                FontSize="{StaticResource SmallFontSize}"
                                TextWrapping="Wrap" VerticalAlignment="Center"
                                Text="{Binding FactoryVelocityIndicator, StringFormat={x:Static props:Resources.velocityIndicator_tooltip}}"/>
                        </Grid>
                        
                    </Grid>
                    
                    





                </StackPanel>

                <StackPanel Orientation="Vertical" Grid.Column="1" Margin="40,0,0,0"  VerticalAlignment="Top">

                    
                    <TextBlock
                        Text="{x:Static props:Resources.My_engagement}"
                        Foreground="{StaticResource LabelBrush}"
                        FontWeight="Bold"
                        HorizontalAlignment="Center" Margin="0,0,0,10"/>
                    
                    <ListBox
                        ItemContainerStyle="{StaticResource NoSelectionListBoxItem}"
                        ItemsSource="{Binding UserEngages}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="0,3,0,3">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto"/>
                                        <ColumnDefinition Width="150"/>
                                    </Grid.ColumnDefinitions>
                                    <ComboBox                     
                                        Grid.Column="0" VerticalAlignment="Center" Margin="0,0,10,0"
                                        Style="{StaticResource MemberAllocationComboBox}"
                                        SF_Comp:CommandBehavior.RoutedEventName="SelectionChanged"  
                                        SF_Comp:CommandBehavior.TheCommandToRun="{Binding Model.ChangeUserEngageCommand, ElementName=thisView}"
                                        SF_Comp:CommandBehavior.TheCommandParameter="{Binding .}"
                                        SelectedValue="{Binding DayAllocation}">
                                    </ComboBox>
                                    <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Column="1">
                                        <TextBlock Style="{StaticResource dayAllocationTextBlock}" DataContext="{Binding DayAllocation}"/>
                                        <TextBlock Text="{x:Static props:Resources._hrs_as_}"/>
                                        <TextBlock Text="{Binding Role.RoleName}" FontWeight="DemiBold" />
                                    </TextBlock>

                                    <DockPanel Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Style="{StaticResource ItemActionMenu}">
                                        <Button 
                                            DockPanel.Dock="Right"
                                            Style="{StaticResource RemoveActionButton}"
                                            Command="{Binding Model.RemoveUserEngageCommand, ElementName=thisView}"
                                            CommandParameter="{Binding .}"/>
                                    </DockPanel>

                                </Grid>                                
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    
                    <TextBlock Width="180" TextWrapping="Wrap" HorizontalAlignment="Center">
                        <TextBlock Text="{x:Static props:Resources.You_are_not_in_this_project_team}" TextWrapping="Wrap" Margin="0,0,0,7"/>
                        <LineBreak/>
                        <Hyperlink Command="{Binding JoinProjectCommand}">
                            <Run FontSize="{StaticResource SmallFontSize}" Text="{x:Static props:Resources.Click_here_to_join_the_project}" />
                        </Hyperlink>
                        <TextBlock.Style>
                            <Style>
                                <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding UserEngages.Count}" Value="0">
                                        <Setter Property="TextBlock.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                    
                    <Separator HorizontalAlignment="Stretch" Height="2" Margin="10,10,0,10" />

                    <TextBlock Text="{x:Static props:Resources.Scrum_Master}"
                           Foreground="{StaticResource LabelBrush}" HorizontalAlignment="Center"
                           FontWeight="Bold"
                           Margin="0,0,0,10"/>
                    <ContentControl                                
                                DataContext="{Binding ProjectScrumMaster}"
                                Width="60" Height="60" Padding="6" 
                                HorizontalAlignment="Center" VerticalAlignment="Top"
                                Style="{StaticResource MemberImageNoIndicatorControlStyle}"/>
                    <TextBlock Text="{Binding ProjectScrumMaster.FullName}" HorizontalAlignment="Center" Margin="10,5,0,5"/>                    
                   

                    <Separator HorizontalAlignment="Stretch" Height="2" Margin="10,10,0,10" />

                    <TextBlock Margin="0,0,0,0" ToolTip="{Binding Project.CodeRepositoryPath}">
                        <Image Source="/Images/Toolbar/folder.png" Width="16" Height="16" VerticalAlignment="Bottom" />
                        <Hyperlink Command="{Binding ShowRepositoryCommand}" CommandParameter="{Binding Project.CodeRepositoryPath}">                            
                            <Run Text="{x:Static props:Resources.Code_rep}" />
                        </Hyperlink>
                        <TextBlock.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Project.CodeRepositoryPath}" Value="{x:Null}">
                                        <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Project.CodeRepositoryPath}" Value="">
                                        <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>

                    <TextBlock Margin="0,10,0,0" ToolTip="{Binding Project.DocRepositoryPath}">
                        <Image Source="/Images/Toolbar/folder.png" Width="16" Height="16" VerticalAlignment="Bottom" />
                        <Hyperlink Command="{Binding ShowRepositoryCommand}" CommandParameter="{Binding Project.DocRepositoryPath}">                            
                            <Run Text="{x:Static props:Resources.Doc_rep}" />
                        </Hyperlink>
                        <TextBlock.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Project.DocRepositoryPath}" Value="{x:Null}">
                                        <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Project.DocRepositoryPath}" Value="">
                                        <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>

                </StackPanel>
                
            </Grid>
           
            
        </SF_Helpers:PanelLayout.Content>
    </SF_Helpers:PanelLayout>

</UserControl>
